﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using IHISCETeim.Model;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using FineUI;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Data;

namespace IHISCETeim.Web.AgentSys.SysMgr
{
    public partial class ChangePW : AgentPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            // 检查当前密码是否正确
            string oldPass = StringHelper.GetPwdEncrypt(tbxOldPassword.Text.Trim());
            string newPass = tbxNewPassword.Text.Trim();
            string confirmNewPass = tbxConfirmNewPassword.Text.Trim();

            if (newPass != confirmNewPass)
            {
                tbxConfirmNewPassword.MarkInvalid("确认密码和新密码不一致！");
                return;
            }
            if (oldPass != User.PassWord)
            {
                tbxOldPassword.MarkInvalid("当前密码不正确！");
                return;
            }
            if (OUserController.EditPwd(User.UserId, StringHelper.GetPwdEncrypt(newPass)))
            {
                Alert.Show("修改密码成功！");
            }
            
        }
    }
}